/*
 * $Id: TextFieldTag.java 651946 2008-04-27 13:41:38Z apetrelli $
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package com.framework.base.taglib.ui;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.BodyTagSupport;

import com.framework.base.util.StringUtil;

/**
 * Description:用于输出文本框

 * tabaleName(对应的表名):
 * Company: framework
 * @author：HYH
 * @version 1.0
 * @Date 2011-6-11 下午12:37:06
 */
@SuppressWarnings("serial")
public class TextFieldTag extends BodyTagSupport {

	private String id="";
	private String name="";
	private String value="";
	private String style="";
	private String styleClass="";
	private String onclick="";
	private String readonly;
	private String validateType; //验证类型
	private String validateMsg;//验证消息
	private String maxLength; //长度
	private String operation="";//用于控制权限
	private String tagContent;//标签内容
	
	@Override
	public int doStartTag() throws JspException {
		JspWriter out = pageContext.getOut();
		StringBuffer contentsb=new StringBuffer("<input  type=\"text\" ");
		contentsb.append(StringUtil.isNullorEmpty(getId())?"":"id=\""+getId()+"\" ");
		contentsb.append(StringUtil.isNullorEmpty(getName())?"":"name=\""+getName()+"\" ");
		contentsb.append(StringUtil.isNullorEmpty(getValue())?"":"value=\""+getValue()+"\" ");
		contentsb.append(StringUtil.isNullorEmpty(getStyle())?"":"style=\""+getStyle()+"\" ");
		contentsb.append(StringUtil.isNullorEmpty(getStyleClass())?"":"class=\""+getStyleClass()+"\" ");
		contentsb.append(StringUtil.isNullorEmpty(getOnclick())?"":"onclick=\""+getOnclick()+"\" ");
		contentsb.append(StringUtil.isNullorEmpty(getReadonly())?"":"readonly=\""+getReadonly()+"\" ");
		contentsb.append(StringUtil.isNullorEmpty(getValidateMsg())?"":"validateMsg=\""+getValidateMsg()+"\" ");
		contentsb.append(StringUtil.isNullorEmpty(getValidateType())?"":"validateType=\""+getValidateType()+"\" ");
		contentsb.append(StringUtil.isNullorEmpty(getMaxLength())?"":"maxlength=\""+getMaxLength()+"\" ");
		try {
			out.print(contentsb.toString()+">");
		} catch (IOException e) {
			e.printStackTrace();
		}
		return EVAL_BODY_INCLUDE;
	}
	public String getReadonly() {
		return readonly;
	}
	public void setReadonly(String readonly) {
		this.readonly = readonly;
	}
	@Override
	public int doEndTag() throws JspException {
		JspWriter out = pageContext.getOut();
		try {
			out.print("</a>");
		} catch (IOException e) {
			e.printStackTrace();
		}
		return super.doEndTag();
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getValue() {
		return value;
	}
	public void setValue(String value) {
		this.value = value;
	}
	public String getStyle() {
		return style;
	}
	public void setStyle(String style) {
		this.style = style;
	}
	public String getStyleClass() {
		return styleClass;
	}
	public void setStyleClass(String styleClass) {
		this.styleClass = styleClass;
	}
	public String getOnclick() {
		return onclick;
	}
	public void setOnclick(String onclick) {
		this.onclick = onclick;
	}
	
	public String getOperation() {
		return operation;
	}
	public void setOperation(String operation) {
		this.operation = operation;
	}
	public String getTagContent() {
		return tagContent;
	}
	public void setTagContent(String tagContent) {
		this.tagContent = tagContent;
	}
	public String getValidateType() {
		return validateType;
	}
	public void setValidateType(String validateType) {
		this.validateType = validateType;
	}
	public String getValidateMsg() {
		return validateMsg;
	}
	public void setValidateMsg(String validateMsg) {
		this.validateMsg = validateMsg;
	}
	public String getMaxLength() {
		return maxLength;
	}
	public void setMaxLength(String maxLength) {
		this.maxLength = maxLength;
	}
	
}
